<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
看书：<input type="checkbox" name="checkbox" value=1><br>
写字：<input type="checkbox" name="checkbox"value=2><br>
打飞机：<input type="checkbox" name="checkbox"value=3><br>
玩游戏：<input type="checkbox" name="checkbox"value=4><br>
<button onclick="checkboxed('checkbox')">全选</button>
<button onclick="uncheckboxed('checkbox')">取消全选</button>
<button onclick="checktiggle('checkbox')">一键</button>
<script>
    function checkboxed(name) {
        var c = document.getElementsByName(name);
        for(var i = 0; i < c.length; i++){
            c[i].checked = "checked";
        }
    }

    function uncheckboxed(name) {
        var c= document.getElementsByName(name);
        for(var i = 0; i < c.length; i++){
            c[i].checked = "";
        }
    }
    var checkAll = false;
    function checktiggle(name) {
        var c= document.getElementsByName(name);
        checkAll = !checkAll;
        for(var i = 0; i < c.length; i++){
            c[i].checked = checkAll;
        }
    }
</script>
</body>
</html>